-module(rtps_participant_sup).

-behaviour(supervisor).

%% API
-export([start_link/3]).

%% Supervisor callbacks
-export([init/1]).

%%====================================================================
%% API functions
%%====================================================================

start_link(Id, Reg, Opts) ->
    supervisor:start_link(?MODULE, [Id, Reg, Opts]).

%%====================================================================
%% Supervisor callbacks
%%====================================================================

%% @private
init([Guid_prefix, Reg, Opts]) ->
    Opts1 = [{guid_prefix, Guid_prefix} | Opts],
    {ok, {#{strategy => one_for_all},
	  [#{id => registry,
	     start => {rtps_reg, start_link, []},
	     restart => permanent,
	     type => worker},
	   #{id => endpoints,
	     start => {rtps_ofo_sup, start_link, []},
	     restart => permanent,
	     type => supervisor},
	   #{id => participant,
	     start => {rtps_participant, start_link, [self(), Guid_prefix, Reg, Opts1]},
	     restart => permanent,
	     type => worker},
	   #{id => spdp,
	     start => {rtps_spdp, start_link, [self(), Opts1]},
	     restart => permanent,
	     type => worker},
	   #{id => sedp,
	     start => {rtps_sedp, start_link, [self(), Opts1]},
	     restart => permanent,
	     type => worker}
	  ]}}.

%%====================================================================
%% Internal functions
%%====================================================================
